# mums = [-1, 0, 3, 5, 9, 12]
# target = 9

def search(nums: list[int], target: int) -> int:
    # 左节点
    left = 0
    # 右节点
    right = len(nums) - 1
    while (left <= right):
        middle = left + (right - left) // 2
        if target < nums[middle]:
            right = middle - 1
        elif target > nums[middle]:
            left = middle + 1
        else:
            return middle
    return -1

result = search([-1, 0, 2, 3, 5, 9, 12], 2)
print(result)



